﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Biz_Dal.Biz;

namespace Project_BookIdeas
{
    public partial class FormDangNhap : Form
    {
        public FormDangNhap()
        {
            InitializeComponent();
        }

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            List<BizKhachHang> list = BizKhachHang.LoginAdmin(txtTenDangNhap.Text, txtMatKhau.Text);
            if (list.Count == 0)
            {
                if (MessageBox.Show("Đăng nhập không thành công!", "Lỗi!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question) == DialogResult.Retry)
                {
                    txtTenDangNhap.Clear();
                    txtMatKhau.Clear();
                    txtTenDangNhap.Focus();
                }
                else
                {
                    this.Close();
                }
            }
            else
            {
                User.UserDangNhap = (BizKhachHang)list[0];
                txtTenDangNhap.Clear();
                txtMatKhau.Clear();
                txtTenDangNhap.Focus();
                FormMain frm = new FormMain();
                this.Hide();
                frm.ShowDialog();
                this.Show();
            }
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

    }
}
